from collections import Counter
import csv

with open('scores.csv', 'r') as file:
    reader  = csv.reader(file)
    next(reader)
    data  =  list(reader)

scores = []
for row in data:
        print(row)
        scores.append(int(row[2]))

for score in scores:
    print(score)

def calc_mean(scores):
    return sum(scores) / len(scores)
    pass

def calc_median(scores):
    sorted_scores = sorted(scores)
    n = len(sorted_scores)
    midpoint = n // 2
    if n % 2 == 0:
        return(sorted_scores[midpoint - 1] + sorted_scores[midpoint]) / 2.0
    else:
        return sorted_scores[midpoint]
    pass

def calc_mode(scores):
    counts = {}
    for score in scores:
        if score in counts.keys():
            counts[score] += 1
        else:
            counts[score] = 1
    mode = max(counts.values())
    for score, count in counts.items():
        if count == mode:
            return score
    pass

mean = calc_mean(scores)
median = calc_median(scores)
mode = calc_mode(scores)


print(f"The mean is {mean}")
print(f"The median is {median}")
print(f"The mode is {mode}")